package com.qmyx.supply.admin.controller;

import com.ytjj.qmyx.supplychain.common.model.request.*;
import com.ytjj.qmyx.supplychain.common.api.CommonResult;
import com.ytjj.qmyx.supplychain.service.BankerBrandService;
import com.ytjj.qmyx.supplychain.service.BankerInfoService;
import com.ytjj.qmyx.supplychain.service.BankerSiteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/brand")
@Slf4j
public class BankerBrandController {
    @Autowired
    private BankerBrandService bankerBrandService;
    @Autowired
    private BankerInfoService bankerInfoService;
    @Autowired
    private BankerSiteService bankerSiteService;

    @PostMapping("/save")
    public CommonResult save(@RequestBody(required = false) BankerInfoRequest bankerInfoRequest) {
        return bankerBrandService.save(bankerInfoRequest);
    }

    /**
     * 审核供应商主体信息
     * @param request
     * @return
     */
    @PostMapping("/checkBanker")
    public CommonResult checkBanker(@RequestBody BankerCheckStatusRequest request) {
        return bankerInfoService.checkStatus(request);
    }

    /**
     * 审核供应商店铺信息
     * @param request
     * @return
     */
    @PostMapping("/checkBankerSite")
    public CommonResult checkBankerSite(@RequestBody BankerCheckStatusRequest request) {
        return bankerSiteService.checkStatus(request);
    }

    /**
     * 审核供应商品牌信息
     * @param request
     * @return
     */
    @PostMapping("/checkBankerBrand")
    public CommonResult checkBankerBrand(@RequestBody BankerCheckStatusRequest request) {
        return bankerBrandService.checkStatus(request);
    }

    /**
     * 单个品牌新增
     * @param request
     * @return
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody BankerBrandRequest request) {
        return bankerBrandService.singleSave(request);
    }

    /**
     * 获取单个品牌信息
     * @param id
     * @return
     */
    @GetMapping("/brandDetail")
    public CommonResult brandDetail(Integer id) {
        return bankerBrandService.getDetail(id);
    }

    /**
     * 单个品牌修改
     * @param request
     * @return
     */
    @PostMapping("/update")
    public CommonResult update(@RequestBody BankerBrandRequest request) {
        return bankerBrandService.singleUpdate(request);
    }

    /**
     * 品牌库列表
     * @param request
     * @return
     */
    @GetMapping("/list")
    public CommonResult list(BankerBrandListRequest request) {
        return CommonResult.success(bankerBrandService.list(request));
    }

    /**
     * 释放主体信息
     * @param request
     * @return
     */
    @PostMapping("/release_info")
    public CommonResult releaseInfo(@RequestBody BankerUpdateReleaseRequest request) {
        return bankerInfoService.release(request);
    }

    /**
     * 释放店铺信息
     * @param request
     * @return
     */
    @PostMapping("/release_site")
    public CommonResult releaseSite(@RequestBody BankerUpdateReleaseRequest request) {
        return bankerSiteService.release(request);
    }

    /**
     * 释放品牌
     * @param request
     * @return
     */
    @PostMapping("/release_brand")
    public CommonResult releaseBrand(@RequestBody BankerUpdateReleaseRequest request) {
        return bankerBrandService.release(request);
    }

    /**
     * 品牌上下架
     */
    @PostMapping("/brandPutOn")
    public CommonResult brandPutOn(@RequestBody BankerUpdatePutOnRequest request) {
        return bankerBrandService.brandPutOn(request);
    }

    /**
     * 查询三步曲保存的供应商信息
     * @return
     */
    @GetMapping("/bankerDetailInfo")
    public CommonResult getBankerDetailInfo() {
        return bankerBrandService.getBankerDetailInfo();
    }

    /**
     * 历史供应商数据生成品牌信息
     * @return
     */
    @PostMapping("/buildOldData")
    public CommonResult buildOldData() {
        boolean result = bankerBrandService.buildOldData();
        return result ? CommonResult.success() :CommonResult.failed();
    }

    /**
     * 查询供应商下的所有品牌信息
     * @return
     */
    @GetMapping("/queryAllBrandList")
    public CommonResult queryAllBrandList() {
        return bankerBrandService.queryAllBrandList();
    }

    /**
     * 修改供应商品牌名称
     * @param request
     * @return
     */
    @PostMapping("/updateBrandName")
    public CommonResult updateBrandName(@RequestBody BrandUpdateNameRequest request) {
        return bankerBrandService.updateBrandName(request);
    }

    /**
     * 供应商店铺下架
     */
    @PostMapping("/bankerSitePutOn")
    public CommonResult bankerSitePutOn(@RequestBody BankerUpdatePutOnRequest request) {
        return bankerSiteService.updateBankerSitePutOn(request);
    }

}
